package com.ptu.service.impl;

import com.ptu.entity.Employee;
import com.ptu.entity.Position;
import com.ptu.mapper.EmployeeMapper;
import com.ptu.mapper.PositionMapper;
import com.ptu.service.PositionService;
import com.ptu.util.DBUtil;

import java.util.List;


    public class PositionServiceImpl implements PositionService {
        @Override
        public List<Position> selectAll() {

            PositionMapper mapper = DBUtil.getSqlSession().getMapper(PositionMapper.class);

            List<Position> list = mapper.selectAll();

            DBUtil.closeAll();
            return list;
        }



        @Override
        public int insert(Position pos) {
            PositionMapper mapper = DBUtil.getSqlSession().getMapper(PositionMapper.class);
            int insert = mapper.insert(pos);

            DBUtil.closeAll();
            return insert;
        }

        @Override
        public int positionupdate(Position pos) {
            PositionMapper mapper = DBUtil.getSqlSession().getMapper(PositionMapper.class);

            int update = mapper.update(pos);

            DBUtil.closeAll();
            return update;
        }

        @Override
        public int delPos(int pos) {
            PositionMapper mapper = DBUtil.getSqlSession().getMapper(PositionMapper.class);

            int i = mapper.delPos(pos);

            DBUtil.closeAll();
            return i;
        }

//        @Override
//        public Employee findEmpByEmpid(String empid) {
//            EmployeeMapper mapper = DBUtil.getSqlSession().getMapper(EmployeeMapper.class);
//            Employee emp = mapper.selectEmpByEmpid(empid);
//            DBUtil.closeAll();
//            return emp;
//        }
        @Override
        public Position findPosByposid(String posid) {
            PositionMapper mapper = DBUtil.getSqlSession().getMapper(PositionMapper.class);
            Position pos = mapper.selectPosByPosid(posid);
            DBUtil.closeAll();
            return pos;
        }


    }
